<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改集中器设备数据')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-data-edit" th:object="${baseConcentratorData}">
            <input type="hidden" id="status" th:value="${baseConcentratorData.concentratorId}">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">集中器ID：</label>
                <div class="col-sm-8">
                    <input name="concentratorId" id="concentratorId" th:field="*{concentratorId}" class="form-control" minlength="4" type="text" readonly required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">集中器型号：</label>
                <div class="col-sm-8">
                    <select name="typeId" class="form-control">
                        <option th:each="concentrator : ${concentratorList}" th:text="${concentrator['typeName']}" th:value="${concentrator['typeId']}" th:field="*{typeId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">安装时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="installTime" th:value="${#dates.format(baseConcentratorData.installTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">安装地址：</label>
                <div class="col-sm-8">
                    <textarea name="installAddress" class="form-control">[[*{installAddress}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">安装位置：</label>
                <div class="col-sm-8">
                    <textarea name="installPosition" class="form-control">[[*{installPosition}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">安装人：</label>
                <div class="col-sm-8">
                    <input name="installUser" th:field="*{installUser}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">Sim卡号：</label>
                <div class="col-sm-8">
                    <input name="concentratorSim" th:field="*{concentratorSim}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">运营商：</label>
                <div class="col-sm-8">
                    <input name="concentratorYys" th:field="*{concentratorYys}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">资费到期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="concentratorZfdq" th:value="${#dates.format(baseConcentratorData.concentratorZfdq, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">资费说明：</label>
                <div class="col-sm-8">
                    <input name="concentratorZfsm" th:field="*{concentratorZfsm}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "module/concentrator/data";
        $("#form-data-edit").validate({
            onkeyup: false,
            rules: {
                concentratorId: {
                    remote: {
                        url: prefix + "/checkConcentratorDataCodeUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "concentratorId": function() {
                                return $.common.trim($("#concentratorId").val());
                            },
                            "status": function() {
                                return $.common.trim($("#status").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "concentratorId": {
                    remote: "集中器ID已存在"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-data-edit').serialize());
            }
        }

        $("input[name='installTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='concentratorZfdq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>